package com.micro.school.edu.controller;

import java.util.List;

import com.micro.school.common.core.utils.poi.ExcelUtil;
import com.micro.school.common.core.web.controller.BaseController;
import com.micro.school.common.core.web.domain.AjaxResult;
import com.micro.school.common.core.web.page.TableDataInfo;
import com.micro.school.common.log.annotation.Log;
import com.micro.school.common.log.enums.BusinessType;
import com.micro.school.common.security.annotation.RequiresPermissions;
import com.micro.school.edu.domain.vo.SchoolCampusVo;
import com.micro.school.edu.service.ISchoolCampusService;
import com.micro.school.system.api.domain.vo.SchoolCampusVos;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 校区信息Controller
 *
 * @author rakic
 * @date 2025-08-06
 */
@RestController
@RequestMapping("/campus")
public class SchoolCampusController extends BaseController
{
    @Autowired
    private ISchoolCampusService schoolCampusService;

    /**
     * 查询校区信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SchoolCampusVo schoolCampusVo)
    {
        startPage();
        List<SchoolCampusVo> list = schoolCampusService.selectSchoolCampusList(schoolCampusVo);
        return getDataTable(list);
    }
    /**
     * 查询列表不分页
     */
    @PostMapping("/getCampusLists")
    public  AjaxResult getCampusLists(@RequestBody SchoolCampusVos schoolCampusVos)
    {
        List<SchoolCampusVos> list = schoolCampusService.selectSchoolCampusLists(schoolCampusVos);
        return success(list);
    }

    /**
     * 查询列表不分页
     */
    @PostMapping("/getCampusLists1")
    public  AjaxResult getCampusLists1(@RequestBody SchoolCampusVos schoolCampusVos)
    {
        List<SchoolCampusVos> list = schoolCampusService.selectSchoolCampusLists1(schoolCampusVos);
        return success(list);
    }

    /**
     * 查询列表不分页
     */
    @GetMapping("/getCampusList")
    public  AjaxResult getCampusList(SchoolCampusVo schoolCampusVo)
    {
        List<SchoolCampusVo> list = schoolCampusService.selectSchoolCampusList(schoolCampusVo);
        return success(list);
    }
    /**
     * 导出校区信息列表
     */
    @Log(title = "校区信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SchoolCampusVo schoolCampusVo)
    {
        List<SchoolCampusVo> list = schoolCampusService.selectSchoolCampusList(schoolCampusVo);
        ExcelUtil<SchoolCampusVo> util = new ExcelUtil<SchoolCampusVo>(SchoolCampusVo.class);
        util.exportExcel(response, list, "校区信息数据");
    }

    /**
     * 获取校区信息详细信息
     */
    @GetMapping(value = "/feign/{id}")
    public AjaxResult getFeignInfo(@PathVariable("id") Long id)
    {
        return success(schoolCampusService.selectSchoolCampusByIds(id));
    }




    /**
     * 获取校区信息详细信息
     */
    @PostMapping(value = "/getAllCampusIdVos")
    public AjaxResult getAllCampusIdVos(@RequestBody SchoolCampusVos schoolCampusVos)
    {
        return success(schoolCampusService.getAllCampusIdVos(schoolCampusVos));
    }

    /**
     * 获取校区信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(schoolCampusService.selectSchoolCampusById(id));
    }

    /**
     * 新增校区信息
     */
    @Log(title = "校区信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchoolCampusVo schoolCampusVo)
    {
        return schoolCampusService.insertSchoolCampus(schoolCampusVo);
    }

    /**
     * 修改校区信息
     */
    @Log(title = "校区信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchoolCampusVo schoolCampusVo)
    {
        return toAjax(schoolCampusService.updateSchoolCampus(schoolCampusVo));
    }

    /**
     * 删除校区信息
     */
    @Log(title = "校区信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        SchoolCampusVo schoolCampusVo=new SchoolCampusVo();
        schoolCampusVo=schoolCampusService.selectSchoolCampusById(ids.get(0));
        schoolCampusVo.setDeleteFlag("1");
        return toAjax(schoolCampusService.updateSchoolCampus(schoolCampusVo));
    }
//    public AjaxResult remove(@PathVariable List<Long> ids)
//    {
//        return toAjax(schoolCampusService.deleteSchoolCampusByIds(ids));
//    }


}
